package cn.com.dstz.data.post;

import org.apache.commons.lang.StringUtils;
import org.jsoup.Connection.KeyVal;

public abstract class PostKeyVal implements KeyVal{
	
	public static final String DEFAULT_POST_KEY = "paramStr";
	public static final String DEFAULT_SEP = "~!^$";
	public static final String AT_SEP = "|@!@|";
	
	private String requestKey;
	
	public PostKeyVal( ){
		this.requestKey = DEFAULT_POST_KEY;
	}
	
	public PostKeyVal( String requestKey ){
		this.requestKey = requestKey;
	}
	
	public  String key( ){
		return requestKey;
	}

	public KeyVal key( String arg0 ) {
		return null;
	}

	public  String value( ){
		return processValue( );
	}
	
	public abstract String processValue( );

	public KeyVal value( String arg0 ) {
		return null;
	}
	
	public void appendToBufferWithDefaultSep( StringBuffer buffer, Object value, boolean appendSep ){
		buffer.append( value );
		if( appendSep ){
			buffer.append( DEFAULT_SEP );
		}
	}
	
	public void appendToBufferWithAtSep( StringBuffer buffer, Object value, boolean appendSep ){
		buffer.append( value );
		if( appendSep ){
			buffer.append( AT_SEP );
		}
	}
	
	public String deleteWhiteSpace( String content ){
		return StringUtils.isNotBlank( content ) ? StringUtils.deleteWhitespace( content ) : content;
	}
	
}
